<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="sec"
	uri="http://www.springframework.org/security/tags"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.util.*"%>
<%@ page import="com.sci99.ex.model.*"%>
<%@ page import="com.sci99.ex.util.*"%>
<%@ page import="org.apache.log4j.Logger"%>
<%@ page import="org.apache.commons.lang3.math.NumberUtils"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt"%>
<%
	Logger log = Logger.getLogger(this.getClass());
    Employee user = UserUtil.getUser();
	request.setAttribute("user", user);

	//log.error(user.getId());
	String sql = "select * from course where id in "
                +"(select course_id from employee_course where employee_id = ?)";
	List r = new ArrayList();
	Connection con = null;
	ResultSet rs = null;
    try {
		con = JDBCUtil.getCon();
		PreparedStatement ps = con.prepareStatement(sql,
				java.sql.ResultSet.TYPE_FORWARD_ONLY,
				java.sql.ResultSet.CONCUR_READ_ONLY);
		ps.setLong(1, user.getId());
		rs = ps.executeQuery();
		while (rs.next()) {
			Map m = new HashMap(8, 1);
			m.put("id", rs.getLong("id"));
			m.put("name", rs.getString("name"));
			m.put("lecturer", rs.getString("lecturer"));
			m.put("period", rs.getString("period"));
			m.put("video_url", VideoUtil.getVideoURL(rs.getLong("id"),rs.getString("video_url")));
			r.add(m);
		}
	} catch (SQLException se) {
		log.error("", se);
	} finally {
		try {
			rs.close();
			con.close();
		} catch (Exception inr) {
			log.error("", inr);
		}
	}
    
	request.setAttribute("rs", r);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>首页</title>
<link href="styles/base.css" rel="stylesheet" type="text/css" />
<link href="styles/common.css" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
	<form id="form1">
		<div class="main_out">
			<div class="main_top">
				<a href=""></a> <span>人力资源培训服务热线：6091073 7071868</span>
			</div>
			<div class="clear"></div>
			<div class="nav">
				<ul class="nav_l">
					<li><a href="index.jsp"
						style="background: #f3f3f3; color: #0186d5 !important">首&nbsp;&nbsp;页</a></li>
					<li><a href="manage.jsp">课程管理</a></li>
					<!--li><a href="search.jsp">课程搜索</a></li -->
					<!--li><a href="add.jsp">课程添加</a></li -->
					<!--li><a href="video.jsp">视频播放</a></li -->
					<!--li><a href="login.jsp">登录页</a></li -->
				</ul>
				<div class="nav_r">
					<a href="j_spring_security_logout">退出登录</a>
				</div>
			</div>
		</div>
		<div class="main">
			<div class="main_l mt">
				<div class="head">
					<span>我的课程列表</span> <a href="manage.jsp"></a>
				</div>
				<div class="content">
					<table cellspacing="0" class="tab_my">
						<thead>
							<tr>
								<th>[已选课程查询]</th>
								<th width="55">[进度]</th>
								<th width="25">&nbsp;</th>
							</tr>
						</thead>
                        <c:forEach items="${rs}" var="mp">
                            <tr>
                                <td><c:out value="${mp.name}" /></td>
                                <td>&nbsp;</td>
                                <td><a href="${mp.video_url}"></a></td>
                            </tr>
                        </c:forEach>
					</table>
				</div>
			</div>
			<div class="main_r mt">
				<div class="welcome">
					<span></span> <img src="images/photo.gif" />姓名：${user.realname}<br />部门：${user.departmentStr}<br />总成绩：90分
					<div class="clear"></div>
				</div>
				<div class="head1 mt">
					<span>最新公告</span>
				</div>
				<div class="content">
					<ul class="ul_w306">
						<li><span>[2012-12-29]</span><a href="#">您的最新考试成绩已经发经发放</a></li>
						<li><span>[2012-12-29]</span><a href="#">新课程《岗位素质模型》已经上传</a></li>
						<li><span>[2012-12-29]</span><a href="#">力资源部门已将课程《怎样....</a></li>
						<li><span>[2012-12-29]</span><a href="#">您的最新考试成绩已经发放</a></li>
						<li><span>[2012-12-29]</span><a href="#">新课程《岗位素质模型》已经上传</a></li>
					</ul>
				</div>
			</div>
			<div class="clear"></div>
		</div>
		<div class="foot_out mt">
			<div class="foot">Copyright &copy; 2004-2012 SCI99 Inc. All
				rights reserved.</div>
		</div>
	</form>
</body>
</html>